package com.yanqu.road.server.gameplayer.module.activity.shuihuyezicard;

import com.yanqu.road.entity.activity.ActivityDisperseGoldInfo;
import com.yanqu.road.entity.activity.ActivityDisperseGoldResult;
import com.yanqu.road.entity.activity.ActivityInfo;
import com.yanqu.road.entity.activity.args.ValueParamArgs;
import com.yanqu.road.entity.activity.shuihuyezipai.*;
import com.yanqu.road.entity.activity.shuihuyezipai.config.ShuiHuYeZiCardCardConfig;
import com.yanqu.road.entity.activity.shuihuyezipai.config.ShuiHuYeZiCardRoomConfig;
import com.yanqu.road.entity.enums.*;
import com.yanqu.road.entity.log.LogShuiHuYeZiCardGetCard;
import com.yanqu.road.logic.bussiness.activity.ShuiHuYeZiCardBusiness;
import com.yanqu.road.pb.activity.ShuiHuYeZiCardProto;
import com.yanqu.road.server.GameServer;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.gameplayer.module.base.GeneralModule;
import com.yanqu.road.server.gameplayer.module.player.BagModule;
import com.yanqu.road.server.gameplayer.module.player.CurrencyModule;
import com.yanqu.road.server.gameplayer.module.player.DecorationModule;
import com.yanqu.road.server.manger.ShuiHuYeZiCardCommonMgr;
import com.yanqu.road.server.manger.activity.ActivityMgr;
import com.yanqu.road.server.manger.activity.shuihuyezicard.ShuiHuYeZiCardMgr;
import com.yanqu.road.server.manger.activity.shuihuyezicard.ShuiHuYeZiCardPVERoom;
import com.yanqu.road.server.manger.config.SystemOpenMgr;
import com.yanqu.road.server.manger.log.LogMgr;
import com.yanqu.road.server.manger.player.UserMgr;
import com.yanqu.road.utils.YanQuMessageUtils;
import com.yanqu.road.server.protocol.ClientProtocol;
import com.yanqu.road.server.protocol.CrossProtocol;
import com.yanqu.road.server.protocol.GameErrorCode;
import com.yanqu.road.utils.date.DateHelper;
import com.yanqu.road.utils.property.Property;
import com.yanqu.road.utils.string.StringUtils;

import java.math.BigInteger;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @Description 水浒叶子牌
 * @Author cwq
 * @Data 2021/12/2 15:48
 */
public class ShuiHuYeZiCardModule extends GeneralModule {

    /**
     * 玩家信息
     */
    private ShuiHuYeZiCardUserData userData;

    /**
     * npc 房间
     */
    private ShuiHuYeZiCardPVERoom npcRoom;

    /**
     * 正在开启的pvp 房间id
     */
    private int pvpRoomId;

    /**
     * 练习 房间
     */
    private ShuiHuYeZiCardPVERoom exerciseRoom;

    /**
     * 对战记录 k:类型 1pve 2pvp
     */
    private HashMap<Integer,List<ShuiHuYeZiCardBattleRecordData>> battleRecordMap = new HashMap<>();

    /**
     * 是否在匹配pvp 中 1表示在匹配中  离线，根据这个状态去区服取消匹配
     */
    private int status;

    public ShuiHuYeZiCardModule(GamePlayer player) {
        super(player);
    }

    @Override
    public boolean loadData() {
        if(ShuiHuYeZiCardMgr.getActivityInfo() != null){
            npcRoom = null;
            battleRecordMap.clear();
            userData = ShuiHuYeZiCardBusiness.getShuiHuYeZiCardUserData(player.getUserId(),ShuiHuYeZiCardMgr.getActivityInfo().getActivityId());
            ShuiHuYeZiCardRoomData roomData = ShuiHuYeZiCardBusiness.getShuiHuYeZiCardRoomData(player.getUserId(),ShuiHuYeZiCardMgr.getActivityInfo().getActivityId());
            if(roomData != null){
                npcRoom = new ShuiHuYeZiCardPVERoom(roomData);
            }
            List<ShuiHuYeZiCardBattleRecordData> list = ShuiHuYeZiCardBusiness.getShuiHuYeZiCardBattleRecordDataList(player.getUserId(),ShuiHuYeZiCardMgr.getActivityInfo().getActivityId());
            if(list != null){
                for (ShuiHuYeZiCardBattleRecordData item : list){
                    addShuiHuYeZiCardBattleRecordData(item);
                }
            }
        }
        return true;
    }

    @Override
    public boolean afterLoadData() {
        return true;
    }

    @Override
    public void afterLogin() {
        sendConfigToClient();
        initUserData();
        toCrossSynUserData();

        synUserData();
    }

    @Override
    public boolean saveData() {
        if(userData != null){
            if(userData.isInsertOption()){
                ShuiHuYeZiCardBusiness.addShuiHuYeZiCardUserData(userData);
            }else if(userData.isUpdateOption()){
                ShuiHuYeZiCardBusiness.updateShuiHuYeZiCardUserData(userData);
            }
        }
        if(npcRoom != null){
            if(npcRoom.getRoomInfo().isInsertOption()){
                ShuiHuYeZiCardBusiness.addShuiHuYeZiCardRoomData(npcRoom.getRoomInfo());
            }else if(npcRoom.getRoomInfo().isUpdateOption()){
                ShuiHuYeZiCardBusiness.updateShuiHuYeZiCardRoomData(npcRoom.getRoomInfo());
            }
        }
        for (List<ShuiHuYeZiCardBattleRecordData> list : battleRecordMap.values()){
            for (ShuiHuYeZiCardBattleRecordData item : list){
                if(item.isInsertOption()){
                    ShuiHuYeZiCardBusiness.addShuiHuYeZiCardBattleRecordData(item);
                }
            }
        }
        return true;
    }


    /**
     * 同步配置
     */
    public void sendConfigToClient() {
        if (ShuiHuYeZiCardMgr.getActivityInfo() == null || !SystemOpenMgr.systemOpen(player, eSystemId.ShuiHuYeZiCardActivity.getValue()) || ShuiHuYeZiCardMgr.getConfig() == null) {
            return;
        }
        player.sendPacket(ClientProtocol.U_SHUIHUYEZICARD_SYN_CONFIG, ShuiHuYeZiCardMgr.builderSyncShuiHuYeZiConfigRespMsg());
    }

    public void initSystem() {
        sendConfigToClient();
        initUserData();
        synUserData();
    }

    /**
     * 初始化玩家信息
     */
    public void initUserData(){
        if (ShuiHuYeZiCardMgr.getActivityInfo() == null || !SystemOpenMgr.systemOpen(player, eSystemId.ShuiHuYeZiCardActivity.getValue())) {
            return;
        }
        synchronized (this){
            // 加载 玩家数据
            if(userData == null || userData.getActivityId() != ShuiHuYeZiCardMgr.getActivityInfo().getActivityId()){
                ShuiHuYeZiCardUserData shuiHuYeZiCardUserData = ShuiHuYeZiCardBusiness.getShuiHuYeZiCardUserData(player.getUserId(),ShuiHuYeZiCardMgr.getActivityInfo().getActivityId());
                if(shuiHuYeZiCardUserData == null){
                    shuiHuYeZiCardUserData = new ShuiHuYeZiCardUserData();
                    shuiHuYeZiCardUserData.setActivityId(ShuiHuYeZiCardMgr.getActivityInfo().getActivityId());
                    shuiHuYeZiCardUserData.setUserId(player.getUserId());
                    shuiHuYeZiCardUserData.setRefreshTime(DateHelper.getCurrentSecond());
                    shuiHuYeZiCardUserData.setInsertOption();
                }
                userData = shuiHuYeZiCardUserData;

                // 查询背包斗牌请帖的数量
                long num = player.getModule(BagModule.class).getUserBagItemCount(eItemId.SHUIHUYEZICARD_INVITATION_ITEM.getValue());
                addPropNum(num,false);

                battleRecordMap.clear();
                List<ShuiHuYeZiCardBattleRecordData> list = ShuiHuYeZiCardBusiness.getShuiHuYeZiCardBattleRecordDataList(player.getUserId(),ShuiHuYeZiCardMgr.getActivityInfo().getActivityId());
                if(list != null){
                    for (ShuiHuYeZiCardBattleRecordData item : list){
                        addShuiHuYeZiCardBattleRecordData(item);
                    }
                }
            }
            // 加载 pve房间数据
            if(npcRoom == null || npcRoom.getRoomInfo().getActivityId() != ShuiHuYeZiCardMgr.getActivityInfo().getActivityId()){
                ShuiHuYeZiCardRoomData pveRoomData = ShuiHuYeZiCardBusiness.getShuiHuYeZiCardRoomData(player.getUserId(),ShuiHuYeZiCardMgr.getActivityInfo().getActivityId());
                if(pveRoomData != null){
                    npcRoom = new ShuiHuYeZiCardPVERoom(pveRoomData);
                }else {
                    npcRoom = null;
                }
            }
        }
    }

    /**
     * 去跨服获取 玩家数据
     */
    public void toCrossSynUserData(){
        if (ShuiHuYeZiCardMgr.getActivityInfo() == null || !SystemOpenMgr.systemOpen(player, eSystemId.ShuiHuYeZiCardActivity.getValue())) {
            return;
        }
        if(ShuiHuYeZiCardCommonMgr.inPvpTime(ShuiHuYeZiCardMgr.getConfig())){
            ShuiHuYeZiCardProto.ShuiHuYeZiCardSynUserInfoGameToCrossMsg.Builder gameToCrossMsg = ShuiHuYeZiCardProto.ShuiHuYeZiCardSynUserInfoGameToCrossMsg.newBuilder();
            if(status == 1){
                // 因为有可能存 玩家被顶号的情况，区服那边又没有走离线取消匹配。
                gameToCrossMsg.setCancelMatch(true);
            }
            player.sendPacket(YanQuMessageUtils.buildMessage(CrossProtocol.C_CROSS_SHUIHUYEZICARD_PVP_SYN_USER_DATA,gameToCrossMsg));
        }

    }

    /**
     * 同步玩家数据
     */
    public void synUserData(){
        if (ShuiHuYeZiCardMgr.getActivityInfo() == null || !SystemOpenMgr.systemOpen(player, eSystemId.ShuiHuYeZiCardActivity.getValue()) || userData == null) {
            return;
        }
        refreshUser();
        ShuiHuYeZiCardProto.GetShuiHuYeZiCardUserRespMsg.Builder builder = ShuiHuYeZiCardProto.GetShuiHuYeZiCardUserRespMsg.newBuilder();
        if(userData != null){
            ShuiHuYeZiCardProto.ShuiHuYeZiCardUserEntity.Builder userEntity = ShuiHuYeZiCardProto.ShuiHuYeZiCardUserEntity.newBuilder();
            userEntity.setRankScore(userData.getRankScore());
            userEntity.setPvpWinningStreakNum(userData.getPvpWinningStreakNum());
            userEntity.setPveWinningStreakNum(userData.getPveWinningStreakNum());

            for (Map.Entry<Integer,Integer> entry : userData.getJoinRoomTimesMap().entrySet()){
                ShuiHuYeZiCardProto.ShuiHuYeZiCardJoinRoomEntity.Builder roomEntity = ShuiHuYeZiCardProto.ShuiHuYeZiCardJoinRoomEntity.newBuilder();
                roomEntity.setRoomId(entry.getKey());
                roomEntity.setTimes(entry.getValue());
                userEntity.addJoinRoomList(roomEntity);
            }
            userEntity.setRefreshTime(userData.getRefreshTime());
            userEntity.setPveRoomId(npcRoom != null ? npcRoom.getRoomInfo().getRoomId() : 0);
            userEntity.setPvpRoomId(pvpRoomId);
            for (ShuiHuYeZiCardUserCard item : userData.getCardMap().values()){
                ShuiHuYeZiCardProto.ShuiHuYeZiCardUserCardEntity.Builder cardEntity = ShuiHuYeZiCardProto.ShuiHuYeZiCardUserCardEntity.newBuilder();
                cardEntity.setId(item.getId());
                cardEntity.setLevel(item.getLevel());
                cardEntity.setNum(item.getNum());
                cardEntity.setQuality(item.getQuality());
                userEntity.addCardList(cardEntity);
            }
            userEntity.setGetPropNum(userData.getGetPropNum());
            builder.setUserData(userEntity);
        }
        player.sendPacket(ClientProtocol.U_SHUIHUYEZICARD_GET_USER_DATA, builder);
    }

    /**
     * 刷新每日房间参与次数
     */
    public void refreshUser(){
        if(userData != null && DateHelper.getDiffDayNum(userData.getRefreshTime()) != 0){
            userData.getJoinRoomTimesMap().clear();
            userData.setRefreshTime(DateHelper.getCurrentSecond());
        }
    }


    public void resetOneDay(){
        if (ShuiHuYeZiCardMgr.getActivityInfo() == null || !SystemOpenMgr.systemOpen(player, eSystemId.ShuiHuYeZiCardActivity.getValue()) || userData == null) {
            return;
        }
        refreshUser();
        synUserData();
    }

    /**
     * 玩家获得卡牌
     * @param addCard 获得的卡牌
     * @return 获得的积分
     */
    public int addCard(ShuiHuYeZiCardGetCardResult addCard,int type ,long addTime){
        ShuiHuYeZiCardUserCard card = userData.getCardMap().get(addCard.getId());
        if(card == null){
            card = new ShuiHuYeZiCardUserCard();
            card.setId(addCard.getId());
            userData.getCardMap().put(addCard.getId(),card);
            userData.setUpdateOption();
        }
        int oldCardLevel = card.getLevel();
        int oldQuality = card.getQuality();
        ShuiHuYeZiCardCardConfig cardConfig = ShuiHuYeZiCardMgr.getConfig().getCardConfigMap().get(addCard.getId());
        int score = cardConfig.getScore();
        int num = 0;
        if(addCard.quality == 1){
            if(card.getQuality() == 0){
                // 升级成金卡
                card.setQuality(1);
                userData.setUpdateOption();
            }else {
                // 转换为n张普通卡
                num = ShuiHuYeZiCardMgr.getConfig().SHUIHUYEZICARD_GOLD_CARD_NUM;
                score = ShuiHuYeZiCardMgr.getConfig().SHUIHUYEZICARD_GOLD_CARD_NUM * cardConfig.getScore();
            }
        }else {
            num = 1;
        }
        for (int i = 0; i < num; i++) {
            if(card.getLevel() >= cardConfig.upgradeConditionList.size()){
                // 满级 获得额外积分
                int extraScore = (cardConfig.getScore() * ShuiHuYeZiCardMgr.getConfig().SHUIHUYEZICARD_CONVERT_VALUE ) / 1000;
                score += extraScore;
            }else {
                // 尝试升级
                card.setNum(card.getNum() + 1);
                Integer needNum = cardConfig.upgradeConditionList.get(card.getLevel());
                if(needNum != null && card.getNum() >= needNum){
                    card.setLevel(card.getLevel() + 1);
                    card.setNum(card.getNum() - needNum);
                }
                userData.setUpdateOption();
            }
        }
        // 加日志
        LogMgr.addLogShuiHuYeZiCardGetCard(new LogShuiHuYeZiCardGetCard(ShuiHuYeZiCardMgr.getActivityInfo().getActivityId(),player.getUserId(),type,card.getId(),oldCardLevel,oldQuality,card.getLevel(),card.getQuality(),card.getNum(),score,addTime));
        return score;
    }

    /**
     * 玩家卡牌 的总等级
     * @return
     */
    public int getCardTotalLevel(){
        int totalLevel = 0;
        if(userData != null){
            for (ShuiHuYeZiCardUserCard item : userData.getCardMap().values()){
                totalLevel += item.getLevel();
            }
        }
        return totalLevel;
    }

    /**
     * 玩家卡牌 金卡数量
     * @return
     */
    public int getGoldCardNum(){
        int num = 0;
        if(userData != null){
            for (ShuiHuYeZiCardUserCard item : userData.getCardMap().values()){
                if(item.getQuality() == 1){
                    num++;
                }
            }
        }
        return num;
    }

    /**
     * 记录胜率 和连胜情况
     * @param rankScore
     * @param isWin
     * @param isNpcModel
     * @param aiIndex
     * @param roomId  房间id
     */
    public void addBattleWinLose(int rankScore,boolean isWin,boolean isNpcModel,int aiIndex,int roomId){
        int level = ShuiHuYeZiCardCommonMgr.getLevel(ShuiHuYeZiCardMgr.getConfig(), rankScore);
        ShuiHuYeZiCardWinOrLoseInfo levelWinOrLoseInfo = userData.getLevelWinLoseMap().get(level);
        if(levelWinOrLoseInfo == null){
            levelWinOrLoseInfo = new ShuiHuYeZiCardWinOrLoseInfo();
            userData.getLevelWinLoseMap().put(level,levelWinOrLoseInfo);
        }
        ShuiHuYeZiCardWinOrLoseInfo roomWinOrLoseInfo = userData.getRoomWinLoseMap().get(roomId);
        if(roomWinOrLoseInfo == null){
            roomWinOrLoseInfo = new ShuiHuYeZiCardWinOrLoseInfo();
            userData.getRoomWinLoseMap().put(roomId,roomWinOrLoseInfo);
        }
        if(isWin){
            levelWinOrLoseInfo.setWinNum(levelWinOrLoseInfo.getWinNum() + 1);
            roomWinOrLoseInfo.setWinNum(roomWinOrLoseInfo.getWinNum() + 1);
        }else {
            levelWinOrLoseInfo.setLoseNum(levelWinOrLoseInfo.getLoseNum() + 1);
            roomWinOrLoseInfo.setLoseNum(roomWinOrLoseInfo.getLoseNum() + 1);
        }

        if(isNpcModel){
            // npc 模式
            ShuiHuYeZiCardWinOrLoseInfo aiWinOrLoseInfo = userData.getAiWinLoseMap().get(aiIndex);
            if(aiWinOrLoseInfo == null){
                aiWinOrLoseInfo = new ShuiHuYeZiCardWinOrLoseInfo();
                userData.getAiWinLoseMap().put(aiIndex,aiWinOrLoseInfo);
            }
            if(isWin){
                aiWinOrLoseInfo.setWinNum(aiWinOrLoseInfo.getWinNum() + 1);
                userData.setPveWinningStreakNum(userData.getPveWinningStreakNum() + 1);
            }else {
                aiWinOrLoseInfo.setLoseNum(aiWinOrLoseInfo.getLoseNum() + 1);
                userData.setPveWinningStreakNum(0);
            }
        }else {
            // 玩家 模式
            if(isWin){
                userData.setPvpWinningStreakNum(userData.getPvpWinningStreakNum() + 1);
            }else {
                userData.setPvpWinningStreakNum(0);
            }
        }
    }

    /**
     * 添加战绩
     * @param battleRecordData
     */
    public void addShuiHuYeZiCardBattleRecordData(ShuiHuYeZiCardBattleRecordData battleRecordData){
        ShuiHuYeZiCardRoomConfig roomConfig = ShuiHuYeZiCardMgr.getConfig().getRoomConfigMap().get(battleRecordData.getRoomType());
        if(roomConfig != null){
            List<ShuiHuYeZiCardBattleRecordData> list = getBattleRecordList(roomConfig.getType(),true);
            synchronized (list){
                if(list.size() >= ShuiHuYeZiCardMgr.getConfig().SHUIHUYEZICARD_BATTLE_RECORD_SHOW_NUM){
                    list.remove(0);
                }
                list.add(battleRecordData);
            }
        }
    }

    /**
     * 加段位分
     * @param addRankScore
     */
    public void addRankScore(int addRankScore){
        userData.setRankScore(Math.max(0, userData.getRankScore() + addRankScore));
        player.notifyListener(eGamePlayerEventType.ShuiHuYeZiCardScoreRank.getValue(), userData.getRankScore());
        player.notifyListener(eGamePlayerEventType.ShuiHuYeZiCardMaxScoreLevel.getValue(),ShuiHuYeZiCardCommonMgr.getLevel(ShuiHuYeZiCardMgr.getConfig(),userData.getRankScore()));
    }


    /**
     * 加抽卡的积分
     * @param addIntegral
     * @param son
     */
    public void addIntegral(int addIntegral,eLogMoneyType son){
        Property integral = new Property();
        integral.addProperty(ShuiHuYeZiCardMgr.getConfig().SHUIHUYEZICARD_SCORE_ID, BigInteger.valueOf(addIntegral));
        userData.setIntegral(userData.getIntegral() + addIntegral);
        player.getModule(CurrencyModule.class).addCurrency(integral, eLogMoneyType.ShuiHuYeZiCardActivity, son);
        player.notifyListener(eGamePlayerEventType.ShuiHuYeZiCardTotalCardLevelRank.getValue(), new ValueParamArgs(getCardTotalLevel(),Integer.toString(userData.getIntegral())));
    }

    /**
     * 添加次数
     */
    public void addJoinRoomTimes(int roomId,int times){
        userData.getJoinRoomTimesMap().put(roomId,userData.getJoinRoomTimesMap().getOrDefault(roomId,0) + times);
        userData.setUpdateOption();
    }

    /**
     * 牌圣送财
     * @param activityInfo 活动信息
     * @return ActivityDisperseGoldResult
     */
    public ActivityDisperseGoldResult disperseGold(ActivityInfo activityInfo,String manifesto) {
        ActivityDisperseGoldResult result = new ActivityDisperseGoldResult();
        if (ShuiHuYeZiCardMgr.getActivityInfo() == null || activityInfo.getActivityId() != ShuiHuYeZiCardMgr.getActivityInfo().getActivityId()) {
            result.setRet(GameErrorCode.E_ACTIVITY_OVER_TIME);
            return result;
        }
        if (!ActivityMgr.activityInShowTime(activityInfo)){
            result.setRet(GameErrorCode.E_SHUIHUYEZICARD_ACTIVITY_NO_OPEN);
            return result;
        }
        // 消耗道具 送福叶子
        Property consume = new Property(eItemId.SHUIHUYEZICARD_DISPERSE_GOLD_ITEM.getValue(), BigInteger.ONE);
        if (!player.getModule(CurrencyModule.class).removeCurrency(consume, eLogMoneyType.ShuiHuYeZiCardActivity, eLogMoneyType.ShuiHuYeZiCardDisperseGold)) {
            result.setRet(GameErrorCode.E_BAG_ITEM_NO_ENOUGH);
            return result;
        }

        List<Integer> decorationIdList = player.getModule(DecorationModule.class).getDecorationIdList(eDecorationType.HonoraryTitle.getValue());
        ActivityDisperseGoldInfo goldInfo = new ActivityDisperseGoldInfo();
        goldInfo.setActivityId(activityInfo.getActivityId());
        goldInfo.setType(activityInfo.getType());
        goldInfo.setUserId(player.getUserId());
        goldInfo.setManifesto(manifesto);
        goldInfo.setBeginTime(System.currentTimeMillis());
        goldInfo.setHonoraryTitles(StringUtils.listToString(decorationIdList, ","));
        goldInfo.setServerList(activityInfo.getServerIdList());
        goldInfo.setUserBaseInfo(UserMgr.getUserBaseInfo(player.getUserId(), GameServer.getInstance().getServerId()));
        result.setGoldInfo(goldInfo);
        return result;
    }


    public List<ShuiHuYeZiCardProto.ShuiHuYeZiCardUserCardEntity> getShuiHuYeZiCardUserCardEntitytList(){
        List<ShuiHuYeZiCardProto.ShuiHuYeZiCardUserCardEntity> list = new ArrayList();
        for (ShuiHuYeZiCardUserCard item : userData.getCardMap().values()){
            ShuiHuYeZiCardProto.ShuiHuYeZiCardUserCardEntity.Builder cardEntity = ShuiHuYeZiCardProto.ShuiHuYeZiCardUserCardEntity.newBuilder();
            cardEntity.setId(item.getId());
            cardEntity.setLevel(item.getLevel());
            cardEntity.setQuality(item.getQuality());
            list.add(cardEntity.build());
        }
        return list;
    }

    /**
     * 获得斗牌数量
     * @param num
     */
    public void addPropNum(long num,boolean isSyn){
        if(userData != null && num > 0){
            userData.setGetPropNum(userData.getGetPropNum() + num);
            if(isSyn){
                synUserData();
            }
        }
    }

    public ShuiHuYeZiCardUserData getUserData() {
        return userData;
    }

    public ShuiHuYeZiCardPVERoom getNpcRoom() {
        return npcRoom;
    }

    public void setNpcRoom(ShuiHuYeZiCardPVERoom npcRoom) {
        this.npcRoom = npcRoom;
    }

    public ShuiHuYeZiCardPVERoom getExerciseRoom() {
        return exerciseRoom;
    }

    public void setExerciseRoom(ShuiHuYeZiCardPVERoom exerciseRoom) {
        this.exerciseRoom = exerciseRoom;
    }

    public int getPvpRoomId() {
        return pvpRoomId;
    }

    public void setPvpRoomId(int pvpRoomId) {
        this.pvpRoomId = pvpRoomId;
    }

    public int getStatus() {
        return status;
    }

    public void setStatus(int status) {
        this.status = status;
    }

    public List<ShuiHuYeZiCardBattleRecordData> getBattleRecordList(int type, boolean newIfNull) {
        List<ShuiHuYeZiCardBattleRecordData> list = battleRecordMap.get(type);
        if(list == null && newIfNull){
            list = new ArrayList<>();
            battleRecordMap.put(type,list);
        }
        return list;
    }
}
